package com.zhihuiyun.library.dialog;

import android.app.Activity;
import android.graphics.drawable.ColorDrawable;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.AdapterView;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.PopupWindow;

import com.zhihuiyun.library.R;
import com.zhihuiyun.library.commonadapter.QuickAdapter;
import com.zhihuiyun.library.commonadapter.ViewHolder;
import com.zhihuiyun.library.view.MyListView;

import java.util.ArrayList;

/**
 * Created by zy on 2018/3/5.
 */

public class TopPopWindow extends PopupWindow {
    private View mView;
    private MyListView listView;
    public  TopPopWindow(Activity paramActivity, AdapterView.OnItemClickListener paramOnClickListener, ArrayList<String> titles,
                         int paramInt1, int paramInt2){
        mView = LayoutInflater.from(paramActivity).inflate(R.layout.popwindow_topright, null);
        listView = (MyListView) mView.findViewById(R.id.popwindow_topright_list);
        if (paramOnClickListener != null){
            //设置点击监听
            listView.setAdapter(new QuickAdapter<String>(paramActivity,R.layout.popwindow_item,titles) {
                @Override
                public void bindData4View(ViewHolder holder, String data, int pos) {
                    holder.setText(R.id.popwindow_item_title,data);
                }
            });
            listView.setOnItemClickListener(paramOnClickListener);
            setContentView(mView);
            //设置宽度
            setWidth(paramInt1);
            //设置高度
            setHeight(paramInt2);
            //设置显示隐藏动画
            setAnimationStyle(R.style.AnimTools);
            //设置背景透明
            setBackgroundDrawable(new ColorDrawable(0));
        }
    }
}
